package edu.sctu.nieyu.day20150614.TestFile;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Created by user01 on 2015/6/14.
 */
public class FileUtil {

    public void addFile(String filepath){

        File file = new File(filepath);
        if (!file.exists()){
            file.mkdir();
        }
        if (!file.exists()){
            try {
                file.createNewFile();
            }catch (IOException e){
                e.printStackTrace();
            }
        }
    }
    public void createFile(File file){
        if (!file.exists()){
            file.mkdir();
        }
    }
    public boolean createNewFile(String filename){
        File file = new File(filename);

        if (!file.exists()){
            try {
                return file.createNewFile();

            } catch (IOException e){
                e.printStackTrace();
            }
        }
        return false;
    }
    public boolean delete(String filename){
        File file = new File(filename);
        if (file.exists()){
        return file.delete();
        }
        return false;

    }

    public String getname(File file){
        if (file.exists()){
            String A = file.getName();
            System.out.println("目录名为："+A);
        }
        return file.getName();
    }
}
